<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>hello world</h1>
<div>
    <input type="file" placeholder="请选择文件" id="myFile">
    <select id ="myType">
        <option>1</option>
        <option>2</option>
        <option>3</option>
    <lect>
    <button class="myButton">提交<tton>
</div>
</body>
<script>
    async function fetchMathod1(url,data){
        let result = fetch(url,
            {
                method: 'POST',
                body: data,
                headers: {
                    'content-type': 'multipart/form-data'
                },
            })
            .then(function(response) {
                return response.json();
            }).then(function(body){
                return body;
            });
        return result;
    }
    async function postFetchSynchronized(url,data){
        return await fetchMathod1(url,data);
    }

    let button = document.querySelector(".myButton")
    button.addEventListener("click", function () {

        let fileInput = document.getElementById("updateInput");
        let resultFile = document.getElementById("updateInput").files[0];
        let myType;
        let options = document.querySelectorAll("option")
        for (let i = 0; i < options.length; i++) {
            if(options[i].selected === true) {
                myType = i;
                break;
            }
        }
        let promise = postFetchSynchronized("http://localhost:8899/convert",{myFile:resultFile,myType:myType})
        promise.then(function (data) {
            alert(data);
        })
    })
    /**
     * 1. 文件
     * 2. 数字
     */



</script>
<ml>
